import { get, post, del, put } from "@/utils/request";
import {
  type companyListParams,
  type companyListReturn,
  type purchaseAddParams,
  type purchaseCheck,
  type purchaseListData,
  type purchaseListParams,
  type purchaseListReturn,
} from "./type";

// 采购列表
export const purchaseList = (data: purchaseListParams) => {
  return get<purchaseListParams, purchaseListReturn>("/api/purchase/list", data);
};

// 提交采购申请
export const purchaseAdd = (data: purchaseAddParams) => {
  return post<purchaseAddParams, purchaseListData>("/api/purchase/add", data);
};

// 删除
export const purchaseDel = (id: number) => {
  return del<number, null>(`/api/purchase/delete/${id}`);
};

// 根据id获取采购物品列表
export const purchaseFoods = (id: number) => {
  return get<number, purchaseListReturn>(`/api/purchaseFoods/list/${id}`);
};

// 根据id获取采购申请信息
export const purchaseGet = (id: number) => {
  return get<number, purchaseListData>(`/api/purchase/get/${id}`);
};

// 收货验收
export const purchaseReceive = (data: purchaseCheck) => {
  return put<purchaseCheck, any>(`/api/purchase/check`, data);
};

// 获取机构列表
export const companyList = (data: companyListParams) => {
  return get<companyListParams, companyListReturn>(`/api/company/list`, data);
};
